package jn.cdz.rabbit.mq.controller;

import jn.cdz.rabbit.mq.entity.User;
import jn.cdz.rabbit.mq.sender.PollingSender;
import jn.cdz.rabbit.mq.sender.PublishSender;
import jn.cdz.rabbit.mq.sender.TopicSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("test")
public class TestController {
    @Autowired
    private PollingSender pollingSender;
    @Autowired
    private TopicSender topicSender;
    @Autowired
    private PublishSender publishSender;

    @RequestMapping("send")
    public void send() {
        for (int i = 0; i < 100; i++) {
            pollingSender.send(11);
        }
    }

    @RequestMapping("topic")
    public void topic() {
        for (int i = 0; i < 100; i++) {
            topicSender.send();
        }
    }

    @RequestMapping("publish")
    public void publish() {
        for (int i = 0; i < 10; i++) {
            publishSender.send(new User(i + "username", i + "password"));
        }
    }
}
